<script>
	function vailadte() {
		if(document.getElementById('txtName').value == '') {
			document.getElementById('txtName').focus();
			alert('กรุณาใส่ชื่อ-นามสกุล');
			return false;
		}
		if(document.getElementById('txtNickName').value == '') {
			document.getElementById('txtNickName').focus();
			alert('กรุณาใส่ชื่อเล่น');
			return false;
		}
		if(document.getElementById('txtSchoolName').value == '') {
			document.getElementById('txtSchoolName').focus();
			alert('กรุณาใส่ชื่อโรงเรียน');
			return false;
		}
		if(document.getElementById('txtCurrentClass').value == '') {
			document.getElementById('txtCurrentClass').focus();
			alert('กรุณาใส่ชั้น');
			return false;
		}
		if(document.getElementById('txtTutorName').value == '') {
			document.getElementById('txtTutorName').focus();
			alert('กรุณาใส่ชื่อติวเตอร์');
			return false;
		}
		if(document.getElementById('txtDetail').value == '') {
			document.getElementById('txtDetail').focus();
			alert('กรุณาใส่รายละเอียดผลงาน');
			return false;
		}
		return true;
			
	}
</script>
<div id="mainContent">
	<form  name="myForm" id="myForm" enctype="multipart/form-data" method="post" action="<?=site_url()?>StudentHallOfFame/saveOutFrame" onsubmit="return vailadte();">
		<input name="txtId" type="hidden" id="txtId" value="<?php if(isset($stu_id)) echo $stu_id; ?>"/> 
		<table width="800px" align="center" cellpadding="2" cellspacing="2" style="border: 1px solid #0000FF; background-color: #FFFFFF">
		  <col width="170px" />
		  <col width="*" />
		  <tr bgcolor="#000974">
		    <td colspan="2" align="left" bgcolor="#000974" style="color:#FFFFFF;"><label>.:: Hall of Fame</label></td>
		  </tr>
		  <tr>
		    <td align="right"><label>ชื่อ - นามสกุล</label><span class="require">*</span></td>
		    <td align="left">
		      <input id="txtName" name="txtName" type="text" value="<?php if(isset($name)) echo $name; ?>"/>   
		 	</td>
		  </tr>
		  <tr>
		    <td align="right"><label>ชื่อเล่น</label><span class="require">*</span></td>
		    <td align="left">
		      <input id="txtNickName" name="txtNickName" type="text" value="<?php if(isset($nick_name)) echo $nick_name; ?>"/>   
		 	</td>
		  </tr>
		  <tr>
		    <td align="right"><label>โรงเรียน</label><span class="require">*</span></td>
		    <td align="left">
		      <input id="txtSchoolName" name="txtSchoolName" type="text" value="<?php if(isset($school_name)) echo $school_name; ?>"/>   
		 	</td>
		  </tr>
		  <tr>
		    <td align="right"><label>ชั้น</label><span class="require">*</span></td>
		    <td align="left">
		      <input id="txtCurrentClass" name="txtCurrentClass" type="text" value="<?php if(isset($current_class)) echo $current_class; ?>"/>   
		 	</td>
		  </tr>
		  <tr>
		    <td align="right"><label>ชื่อติวเตอร์</label><span class="require">*</span></td>
		    <td align="left">
		      <input id="txtTutorName" name="txtTutorName" type="text" value="<?php if(isset($tutor_name)) echo $tutor_name; ?>"/>   
		 	</td>
		  </tr>
		  <tr>
		    <td align="right"><label>รายละเอียดผลงาน</label><span class="require">*</span></td>
		    <td align="left">
		      <textarea rows="6" cols="40" id="txtDetail" name="txtDetail"><?php if(isset($detail)) echo $detail; ?></textarea>
		 	</td>
		  </tr>
		  <tr>
		    <td align="right">&nbsp;</td>
		    <td align="left"><input type="submit" name="button" id="button" value="บันทึกข้อมูล" /> 
		       <input type="submit" name="button4" id="button4" value="ลบข้อมูล" onclick="setTargetForm('delete');"/></td>
		  </tr>
		  <tr style="height:10px;">
		    <td colspan="2"></td>
		  </tr>
		</table>
	</form>
</div>
<script type="text/javascript">
	function setTargetForm(val) {
		var frm = document.forms["myForm"];
		frm.action = "<?=site_url()?>StudentHallOfFame/delete";
		frm.submit();
	}
</script>
